import {getCurrentUser} from "./user.ts";
import {showDialog} from "vant";
import {ref} from "vue";
import {useRouter} from "vue-router";


export const getUserRoleIsAdmin = async () => {
    const res = await getCurrentUser();
    const user = ref();
    user.value = res.data;
    const router = useRouter();
// console.log(user.value.userRole === 'admin')
    if (user?.value?.userRole === 'user' ){
        showDialog({
            message: '您不是管理员.',
        }).then(() => {
            router.push({
                path: '/index',
                replace: true,
            });
        });
    }
}